package com.konne.nightmare.FastPublicOpinion.ui.dialog;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import com.konne.nightmare.FastPublicOpinion.R;
import com.konne.nightmare.FastPublicOpinion.ui.information.activity.MoveClassActivity;
import com.konne.nightmare.FastPublicOpinion.ui.personal.activity.DeviceInfoActivity;
import com.konne.nightmare.FastPublicOpinion.ui.personal.activity.DeviceManageActivity;
import com.konne.nightmare.FastPublicOpinion.utils.TipsUtils;
import com.konne.nightmare.FastPublicOpinion.widget.TriangleView;


/**
 * @Author: chen
 * @UpdateDate: 1/27/22
 * @UpdateRemark:
 */
public class ClassTwoMorePopupWindow extends PopupWindow {
    private static final String TAG = "ClassTwoMorePopupWindow";
    private Context context;
    private View popView;

    private TriangleView triangleView;
    private LinearLayout llEdit;
    private LinearLayout llDelete;
    private LinearLayout llMove;

    public ClassTwoMorePopupWindow(Context context) {
        this.context = context;
        popView = LayoutInflater.from(context).inflate(R.layout.pop_class_two_layout, null, false);
        setContentView(popView);
        setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
        setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        setBackgroundDrawable(new ColorDrawable());
        setOutsideTouchable(true);//点击外部消失
        setTouchable(true); //设置可以点击
        triangleView = (TriangleView) popView.findViewById(R.id.triangleView);
        llEdit = (LinearLayout) popView.findViewById(R.id.ll_edit);
        llDelete = (LinearLayout) popView.findViewById(R.id.ll_delete);
        llMove = (LinearLayout) popView.findViewById(R.id.ll_move);

        triangleView.setTriangleColor(ContextCompat.getColor(context,R.color.white));
        TipsUtils.setBackgroundAlpha((AppCompatActivity) context, 0.6f);

        setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                TipsUtils.setBackgroundAlpha((AppCompatActivity) context, 1.0f);
            }
        });
        llEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        llDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                final ConfirmDialog dialog = new ConfirmDialog(context);
                dialog.setTitle("确认删除“线性代数理论”作业吗");
                dialog.setMessageImage(R.mipmap.icon_class_delete);
                dialog.setMessageColor(R.color.color_67788A);
                dialog.setOkButton("确定", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();

                    }
                });
                dialog.setCancelButton("取消", new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                    }
                });
                dialog.show();
            }
        });
        llMove.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
               context. startActivity(new Intent(context, MoveClassActivity.class));

            }
        });
    }


}
